<?php

/**
 * @Author: Bing
 * @Date:   2019-04-14 17:09:41
 * @Email:  huangfreeze@gmail.com
 * @Last Modified time: 2019-04-30 17:28:28
 */

/**
 * BaseController
 * 监听页面请求过程
 */
class BaseController extends IController
{
	public static function onCreateApp(){}

	public static function onFinishApp(){}

	public static function onBeforeCreateController($ctrlId){}

	public static function onCreateController($ctrlObj){}

	public static function onFinishController($ctrlObj){}

	public static function onBeforeCreateAction($ctrlObj, $actionId) {
		/**
		 * 可微信授权登录的controller
		 */
		$canWechatLoginCtrl = array('ucenter', 'site', 'simple', 'pic', 'block');
		if ( !in_array($ctrlObj->ctrlId, $canWechatLoginCtrl) ) {
			return true;
		}
		/**
		 * 微信授权
		 */
		if ( IClient::isWechat() && !ISafe::get('wechat_openid') ) {
			$url = IUrl::getUrl();
			plugin::trigger('setCallback', $url);

			$app = WechatMp::getApp();
			$app->oauth->redirect()->send();
		}
	}

	public static function onCreateAction($ctrlObj,$actinObj){}

	public static function onFinishAction($ctrlObj,$actinObj){}

	public static function onCreateView($ctrlObj,$actinObj){}

	public static function onFinishView($ctrlObj,$actinObj){}

	public static function onPhpShutDown(){}
}
